﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using AviewMotionUI.ProductionStatistics;
using LanCustomControldll;
using FinalTestMachine.Motion.Products;

namespace FinalTestMachine.View.MainUnits
{
    /// <summary>
    /// Unit_ProductInfo.xaml 的交互逻辑
    /// </summary>
    public partial class Unit_ProductInfo : UserControl,IShow
    {
        public Unit_ProductInfo()
        {
            InitializeComponent();
        }
        public void ClearProduction()
        {
            try
            {
                MessageBoxResult messageBoxResult = MessageBox.Show("Are you sure to empty the current production data?", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning);
                if (messageBoxResult == MessageBoxResult.Yes)
                {
                    ProductionStatisticsManger.Current.Clear();

                  //  ProductNumberManager.Cur.Clear();
                }
            }
            catch (Exception ex)
            {

                MessageBox.Show(ex.Message);
            }
        }
        public void ShowUI()
        {
            //直接统计
            tb_OkProductNum.Text = ProductionStatisticsManger.Current.TotalYieldArray.YieldPercent.KeyCount.ToString();
            tb_NgProductNum.Text = ProductionStatisticsManger.Current.TotalYieldArray.YieldPercent.SpareCount.ToString();
            tb_TotalProductNum.Text = ProductionStatisticsManger.Current.TotalYieldArray.YieldPercent.TotalCount.ToString();

            tb_OKPercent.Text = ProductionStatisticsManger.Current.TotalYieldArray.YieldPercent.Yield.ToString("F2") + "%";

            //tb_OkProductNum.Text = ProductNumberManager.Cur.OKNums.ToString();
            //tb_NgProductNum.Text = ProductNumberManager.Cur.NgNums.ToString();
            //tb_TotalProductNum.Text = ProductNumberManager.Cur.Total.ToString();
            //tb_OKPercent.Text = ProductNumberManager.Cur.Yield.ToString("F2") + "%";
        }
    }
}
